package com.ruoyi.web.controller.book;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.module.business.JdTokenBusiness;
import com.ruoyi.module.domain.JdToken;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 京东到家认证信息Controller
 * 
 * @author ruoyi
 * @date 2022-04-25
 */
@RestController
@RequestMapping("/system/token")
@RequiredArgsConstructor
public class JdTokenController extends BaseController
{
    private final JdTokenBusiness jdTokenBusiness;

    /**
     * 查询京东到家认证信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:token:list')")
    @GetMapping("/list")
    public TableDataInfo list()
    {
        startPage();
        List<JdToken> list = jdTokenBusiness.selectJdTokenList();
        return getDataTable(list);
    }

    /**
     * 获取京东到家认证信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:token:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(jdTokenBusiness.selectJdTokenById(id));
    }

    /**
     * 修改京东到家认证信息
     */
    @PreAuthorize("@ss.hasPermi('system:token:edit')")
    @Log(title = "京东到家认证信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JdToken jdToken)
    {
        return toAjax(jdTokenBusiness.updateJdToken(jdToken));
    }
}
